package co.yixiang.weixin.common.weixin.hystrix;


import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
import co.yixiang.weixin.common.dto.WxPayDto;
import co.yixiang.weixin.common.weixin.feign.RemoteWeixinService;
import co.yixiang.weixin.common.weixin.vo.LoginParam;
import feign.hystrix.FallbackFactory;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 微信服务降级处理
 * @author yshop
 */
@Component
public class RemoteWexinFallbackFactory implements FallbackFactory<RemoteWeixinService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteWexinFallbackFactory.class);

    @Override
    public RemoteWeixinService create(Throwable throwable)
    {
        log.error("微信服务调用失败:{}", throwable.getMessage());
        return new RemoteWeixinService()
        {
            @Override
            public Map<String, Object>  goPay(WxPayDto wxPayDto)
            {
                return null;
            }

            @Override
            public void refreshAllWxConfig() {

            }

            @Override
            public void refreshWxPayConfig() {

            }

            @Override
            public WxMaUserInfo wxMaOauth(LoginParam loginParam) {
                return null;
            }

            @Override
            public WxMpUser wxMpOauth(String code) {
                return null;
            }

            @Override
            public Object unifyPay(String orderId, String from, String attach, String body) {
                return null;
            }
        };
    }
}
